﻿//-----------------------------------------------------------------------
// <copyright file="Product.cs" company="FER">
//     Copyright (c) All rights reserved.
// </copyright>
//-----------------------------------------------------------------------

namespace NMBP.Models
{
    using System.Drawing;
    using System.IO;

    using NMBP.Models.Enums;

    /// <summary>
    /// Represents one product
    /// </summary>
    public class Product
    {
        /// <summary>
        /// Gets or sets products description
        /// </summary>
        public string Description { get; set; }

        /// <summary>
        /// Gets or sets product price
        /// </summary>
        public float Price { get; set; }

        /// <summary>
        /// Gets or sets product availbility
        /// </summary>
        public ProductAvailability Availability { get; set; }

        /// <summary>
        /// Gets or sets in stock value
        /// </summary>
        public long InStock { get; set; }

        /// <summary>
        /// Gets or sets product image
        /// </summary>
        public byte[] Image { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether product is in cart
        /// </summary>
        public bool InCart { get; set; }

        /// <summary>
        /// Sets stock value
        /// </summary>
        /// <param name="value">value to be set</param>
        public void SetStockValue(long value)
        {
            this.InStock = value;

            if (value <= 0)
            {
                this.Availability = ProductAvailability.NotAvailable;
            } 
            else 
                if (value > 0 && value < 10)
            {
                this.Availability = ProductAvailability.AvailableIn24H;
            } 
                else 
                    if (value >= 10)
            {
                this.Availability = ProductAvailability.InStock;
            }
        }
    }
}
